function calPoints(ops: string[]): number {
    let stack = [];
    let result = 0;
    for (let i = 0; i < ops.length; i++) {
        switch (ops[i]){
            case 'C':
                stack.pop();
                break;
            case 'D':
                stack.push(stack[stack.length - 1] * 2);
                break;
            case '+':
                stack.push(stack[stack.length - 1] + stack[stack.length - 2]);
                break;
            default:
                stack.push(Number(ops[i]));
                break;
        }

    }
    for(let i = 0; i < stack.length; i++){
        result += stack[i]
    }
    return result;
};